package main

import (
	"awang/aWeb/aWebUrls"
	"awang/config/middleWare/cors"
	"net/http"

	"github.com/gin-gonic/gin"
	_ "github.com/jinzhu/gorm/dialects/sqlite"
)

func main() {
	// fmt.Println("123")
	runServer()
	// migrateDB()

}

func runServer() {
	router := gin.Default()
	router.Use(cors.Cors())
	router.Delims("{[{", "}]}")
	router.StaticFS("/upload", http.Dir("upload"))
	router.StaticFS("/static", http.Dir("static"))
	// router.GET("/ping", func(c *gin.Context) {
	// 	c.JSON(200, a)
	// })
	// aWebUrls.TemplateUrls(router)
	aWebUrls.WebRoot(router)
	aWebUrls.WebApi(router)
	// {
	// 	v1.POST("/login", loginEndpoint)
	// 	v1.POST("/submit", submitEndpoint)
	// 	v1.POST("/read", readEndpoint)
	// }

	router.Run("0.0.0.0:10300")
}

func migrateDB() {
	// db, _ := gorm.Open("sqlite3", "gorm.db")
	// t_db := db.Connect()
	// t_db.AutoMigrate(&videos.Video{})

	// vv := videos.Video{Name: "234", Urls: "yyy"}
	// db.Create(&vv)

	// defer db.Close()
}
